<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>CruiseControl.NET : Statistics Publisher</title>
	    <link rel="stylesheet" href="styles/site.css" type="text/css" />
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">	    
    </head>

    <body>
	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
		    <tr>
			    <td valign="top" class="pagebody">
				    <div class="pageheader">
					    <span class="pagetitle">
                            CruiseControl.NET : Statistics Publisher
                                                    </span>
				    </div>
				    <div class="pagesubheading">
					    This page last changed on Jun 26, 2009 by <font color="#0050B2">csut017</font>.
				    </div>

				    <p>The publisher can be used to collect and update statistics for each build in a file. Some of the statistics which would be collected are build durations and test count.</p>

<p>At the minimal, the publisher can be configured with just an empty &lt;statistics /&gt; element in the publishers section. This would pick up some default statistics for capturing during the build process.<br/>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;publishers&gt;</span>
     <span class="code-tag">&lt;statistics /&gt;</span>
<span class="code-tag">&lt;/publishers&gt;</span></pre>
</div></div><br clear="all" /></p>

<p><b><em>NOTE:</em></b> Statistics publisher must come after any File Merge tasks in the publishers section, in case you want to collect statistics from merged files.</p>

<p>If you want to specify your own, or override the default statistics, it is possible to do so by supplying the name and xpath for the statistics and the corresponding location in the build log to pick the data from.</p>

<p><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;publishers&gt;</span>
     <span class="code-tag">&lt;statistics&gt;</span>
        <span class="code-tag">&lt;statisticList&gt;</span>
           <span class="code-tag">&lt;statistic name='metric_name' xpath='xpath expression'/&gt;</span>
           <span class="code-tag">&lt;firstMatch name='metric_name' xpath='xpath expression' /&gt;</span>
        <span class="code-tag">&lt;statisticList/&gt;</span>
     <span class="code-tag">&lt;/statistics&gt;</span>
<span class="code-tag">&lt;/publishers&gt;</span></pre>
</div></div><br clear="all" /> <br clear="all" />
<br clear="all" /></p>

<p>FirstMatch is a special type of Statistics where you are only interested in the first occurrence in the build log, like the Project Name.</p>

<p>The task will generate a statistics.csv and report.xml file in the artifact directory.</p>

<h3><a name="StatisticsPublisher-TaskConfiguration"></a>Task Configuration</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Node </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Version </th>
</tr>
<tr>
<td class='confluenceTd'> statisticList </td>
<td class='confluenceTd'> The list of statistics to generate. </td>
<td class='confluenceTd'> List of Statistic elements. </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> empty list </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> dynamicValues </td>
<td class='confluenceTd'> Any dynamic parameters to be used. See <a href="Dynamic Parameters.html" title="Dynamic Parameters">Dynamic Parameters</a> </td>
<td class='confluenceTd'> Dynamic values array - see <a href="Dynamic Parameters.html" title="Dynamic Parameters">Dynamic Parameters</a> </td>
<td class='confluenceTd'> No </td>
<td class='confluenceTd'> <em>None</em> </td>
<td class='confluenceTd'> 1.5.0 </td>
</tr>
</tbody></table>

<p>It is also possible to optionally configure the statistics publisher to generate charts for any metric against different builds, and to even remove them altogether. These features has been added in release <a href="http://ccnetlive.thoughtworks.com/CCNet-builds/1.3/1.3.0.2918/">1.3</a></p>

<p><div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;publishers&gt;</span>
     <span class="code-tag">&lt;statistics&gt;</span>
        <span class="code-tag">&lt;statisticList&gt;</span>
           <span class="code-tag">&lt;statistic name='metric_name' xpath='xpath expression' generateGraph='true' include='true'/&gt;</span>
           <span class="code-tag">&lt;firstMatch name='metric_name' xpath='xpath expression' include='false'/&gt;</span>
        <span class="code-tag">&lt;statisticList/&gt;</span>
     <span class="code-tag">&lt;/statistics&gt;</span>
<span class="code-tag">&lt;/publishers&gt;</span></pre>
</div></div><br clear="all" /> <br clear="all" />
<br clear="all" /></p>

<p>For the statistics configured with "generateGraph='true'", a graph is generated with different builds on x-axis and the configured metric on y-axis in the artifacts directory named as &lt;statistic name&gt;.png. This chart would still be a very basic representation. For now atleast, exporting the report to Excel for charting/analyis might be a better option.</p>

<h3><a name="StatisticsPublisher-MetricsConfiguration"></a>Metrics Configuration</h3>
<p><br clear="all" />
<blockquote>
<p><b><em>statistic &#124; firstMatch</em></b></p></blockquote><br clear="all" /> <br clear="all" />
<br clear="all" /></p>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Attribute </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> Default </th>
</tr>
<tr>
<td class='confluenceTd'> name </td>
<td class='confluenceTd'> Metric Name </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> xpath </td>
<td class='confluenceTd'> xPath for evaluating the statistic </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> generateGraph </td>
<td class='confluenceTd'> true will generate a graph against different builds </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> include </td>
<td class='confluenceTd'> whether to publish statistic for this metric </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> true </td>
</tr>
</tbody></table>

				    
                    			    </td>
		    </tr>
	    </table>
	    <table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td height="12" background="http://confluence.public.thoughtworks.org//images/border/border_bottom.gif"><img src="images/border/spacer.gif" width="1" height="1" border="0"/></td>
			</tr>
		    <tr>
			    <td align="center"><font color="grey">Document generated by Confluence on Sep 29, 2009 20:59</font></td>
		    </tr>
	    </table>
    </body>
</html>